3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
Object creation and deletion is similar to object registration, except that the data being operated on is the instance data. The TQ3XObjectNewMethod method should initialize all data in the private data structure and allocate any memory needed to copy the data in. The TQ3XObjectDeleteMethod method should deallocate any data in the private data structure of the object.
The TQ3XObjectNewMethod function, returned by the kQ3XMethodTypeObjectNew method, initializes data in the object's private data structure and allocates the required memory.
#define kQ3XMethodTypeObjectNew Q3_METHOD_TYPE('n','e','w','o')
typedef TQ3Status (*TQ3XObjectNewMethod)(
TQ3Object object,
void *privateData,
void *parameters);
The TQ3XObjectNewMethod method should initialize all data in the private data structure (possibly with parameters) and allocate any memory needed to copy the data in. If instanceSize in the previous Q3ObjectHierarchy_RegisterClass call was nonzero, a TQ3ObjectNewMethod is required. If instanceSize was 0, the TQ3XObjectNewMethod method is never called.
The TQ3XObjectDeleteMethod function, which is returned by the kQ3XMethodTypeObjectDelete method, deallocates data in the object's private data structure.
The TQ3XObjectDuplicateMethod function, which is returned by the kQ3XMethodTypeObjectDuplicate method, duplicates an object and copies its private instance data.
#define kQ3XMethodTypeObjectDuplicate Q3_METHOD_TYPE('d','u','p','l')
typedef TQ3Status (*TQ3XObjectDuplicateMethod)(
TQ3Object fromObject,
const void *fromPrivateData,
TQ3Object toObject,
const void *toPrivateData);
The TQ3XObjectDuplicateMethod method should copy the private instance data from fromPrivateData to toPrivateData and return kQ3Success if sucessful. Otherwise, it should deallocate anything it has allocated, clean up its parent classes, and return kQ3Failure . TQ3XObjectDuplicateMethod is called in the same way as TQ3XObjectNewMethod and TQ3XObjectDeleteMethod .
The TQ3XObjectUnregisterMethod function, which is returned by the kQ3MethodTypeObjectUnregister method, removes a custom object class.
#define kQ3MethodTypeObjectUnregister Q3_METHOD_TYPE('u','n','r','g')
typedef TQ3Status (*TQ3XObjectUnregisterMethod)
(TQ3XObjectClass objectClass);
Previous | QD3D Book | Overview | Chapter Contents | Next |